package com.sls.web.manager.action.ekhui;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sls.web.manager.action.SuperAction;
import com.sls.web.manager.common.Constants;
import com.sls.web.manager.common.DateUtil;
import com.sls.web.manager.game.client.PaymentClient;
import com.sls.web.manager.game.pojo.ekhui.Payment;
import com.sls.web.manager.game.querybean.GoodsQuery;
import com.sls.web.manager.game.querybean.PaymentQuery;
import com.sls.web.manager.page.Pagination;
import com.sls.web.manager.pojo.UserInfoVO;

public class PaymentAction extends SuperAction {
	private Logger log = LoggerFactory.getLogger(PaymentAction.class) ;
	private List<Payment> paymentList  ;
	private Pagination<Payment> page;
	private Payment payment ;
	private PaymentQuery paymentQuery ;
	protected String startTime ;
	protected String endTime ;
	protected int recordCount ;
	
	public String list(){
		UserInfoVO userInfoVO = getCurrentOperator() ;
		PaymentClient client = PaymentClient.getInstance() ;
		if(payment == null){
			payment = new Payment() ;
		}
		if (paymentQuery == null) {
			paymentQuery = new PaymentQuery();
			paymentQuery.setPageSize(Constants.INIT_PAGESIZE);
			paymentQuery.setCurrentPage(Constants.INIT_CURRENTPAGE);
		}
		recordCount = client.getPaymentCount(userInfoVO, payment, getStartTime(),
				getEndTime()) ;
		
		if(page == null){
			page = new Pagination<Payment>(paymentQuery.getCurrentPage() , recordCount , paymentQuery.getPageSize()) ;
		}
		paymentList = client.getPaymentList(userInfoVO, payment, getStartTime(),
				getEndTime(), page.getCurrentPage(), page.getPageSize()) ;
		
		page.setRowCount(recordCount) ;
		page.setList(paymentList) ;
		
		return "list" ;
	}
	public List<Payment> getPaymentList() {
		return paymentList;
	}
	public void setPaymentList(List<Payment> paymentList) {
		this.paymentList = paymentList;
	}
	public Pagination<Payment> getPage() {
		return page;
	}
	public void setPage(Pagination<Payment> page) {
		this.page = page;
	}
	public Payment getPayment() {
		return payment;
	}
	public void setPayment(Payment payment) {
		this.payment = payment;
	}
	public String getStartTime() {
		if(StringUtils.isBlank(startTime)){
			startTime = DateUtil.getTodayBegin() ;
		}
		return startTime;
	}
	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}
	public String getEndTime() {
		if(StringUtils.isBlank(endTime)){
			endTime = DateUtil.getTodayEnd() ;
		}
		return endTime;
	}
	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}
	public int getRecordCount() {
		return recordCount;
	}
	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
	public PaymentQuery getPaymentQuery() {
		return paymentQuery;
	}
	public void setPaymentQuery(PaymentQuery paymentQuery) {
		this.paymentQuery = paymentQuery;
	}
}
